home *** CD-ROM | disk | FTP | other *** search
/ Revista CD Expert 8 / Revista CD Expert nº 08 CD1.iso / Utilitarios / Programacao / Bloodshed Dev-C++ 2.0 / _SETUP.1 / sehsub.c < prev    next >
C/C++ Source or Header  |  1997-10-28  |  921b  |  44 lines

  1. /*
  2.  * sehsub.c
  3.  *
  4.  * In an attempt to see what might be going on inside CRTDLL, this program
  5.  * walks the exception list after creating a new thread with _beginthread.
  6.  *
  7.  * It turns out that _beginthread DOES install an exception handler, as
  8.  * expected, but this handler is NOT exported by CRTDLL (it is certainly
  9.  * not _except_handler2 or _XcptFilter)... an odd and unpleasant turn of
  10.  * events.
  11.  */
  12.  
  13. #include <windows.h>
  14. #include <excpt.h>
  15. #include <process.h>
  16.  
  17. #include "exutil.h"
  18.  
  19. extern void* __imp__except_handler3;
  20.  
  21. unsigned
  22. my_thread (void * p)
  23. {
  24.     printf ("In my thread.\n");
  25.     WalkExceptionHandlers();
  26.     return 0;
  27. }
  28.  
  29. main ()
  30. {
  31.     unsigned long    h;
  32.     unsigned    id;
  33.     printf ("In main.\n");
  34.     WalkExceptionHandlers();
  35.  
  36.     printf ("Except_handler3 %08x\n", __imp__except_handler3);
  37.     h = _beginthreadex (NULL, 0, my_thread, NULL, 0, &id);
  38.  
  39.     WaitForSingleObject ((HANDLE) h, INFINITE);
  40.     CloseHandle ((HANDLE) h);
  41.     return;
  42. }
  43.  
  44.